package cn.lyh.gulimall.product.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.hibernate.validator.constraints.URL;
import valid.AddGroup;
import valid.ListValue;
import valid.UpdateGroup;
import valid.UpdateBrandStatusGroup;

import javax.validation.constraints.*;

/**
 * @author lyh
 * @version 1.0
 * @since 2021/4/6
 */

/**
 * 品牌
 */
@Data
@TableName(value = "pms_brand")
public class PmsBrand {
	public static final String COL_BRAND_ID = "brand_id";
	public static final String COL_NAME = "name";
	public static final String COL_LOGO = "logo";
	public static final String COL_DESCRIPT = "descript";
	public static final String COL_SHOW_STATUS = "show_status";
	public static final String COL_FIRST_LETTER = "first_letter";
	public static final String COL_SORT = "sort";
	/**
	 * 品牌id
	 */
	@TableId(value = "brand_id", type = IdType.AUTO)
	@NotNull(message = "修改必须指定ID",groups = UpdateGroup.class)
	@Null(message = "新增时候不能指定ID",groups = AddGroup.class)
	private Long brandId;
	/**
	 * 品牌名
	 */
	@TableField(value = "name")
	@NotBlank(message = "品牌名不能为空",groups = {AddGroup.class,UpdateGroup.class})
	private String name;
	/**
	 * 品牌logo地址
	 */
	@TableField(value = "logo")
	@URL(message = "logo地址必须是一个合法的URL地址",groups = {AddGroup.class,UpdateGroup.class})
	@NotEmpty(message = "logo地址不能为空",groups = {AddGroup.class})
	private String logo;
	/**
	 * 介绍
	 */
	@TableField(value = "descript")
	private String descript;
	/**
	 * 显示状态[0-不显示；1-显示]
	 */
	@TableField(value = "show_status")
//	@TableLogic(value = "1",delval = "0")
	@ListValue(values = {(byte)1,(byte)0},groups = {AddGroup.class, UpdateBrandStatusGroup.class},message = "必须提交指定的值：[0,1]")
	@NotNull(groups = {AddGroup.class, UpdateBrandStatusGroup.class})
	private Byte showStatus;
	/**
	 * 检索首字母
	 */
	@TableField(value = "first_letter")
	@Pattern(regexp = "^[a-zA-Z]$",message = "检索首字母必须是一个字母",groups = {AddGroup.class,UpdateGroup.class})
	@NotEmpty(message = "检索首字母不能为空",groups = AddGroup.class)
	private String firstLetter;
	/**
	 * 排序
	 */
	@TableField(value = "sort")
	@NotNull(message = "排序序号必须要填写一个大于等于0的值",groups = AddGroup.class)
	@Min(value = 0,message = "排序必须大于等于0",groups = {AddGroup.class,UpdateGroup.class})
	private Integer sort;
}